package com.managerConsummer.controller;

import com.managerConsummer.service.RoleServiceFeign;
import entity.Role;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 角色控制器
 * The type Role controller.
 *
 * @author tapoliuliyue
 * @date 2022/04/23
 */
@RestController
@RequestMapping("/role")
@CrossOrigin
public class RoleController {
    @Autowired
    private RoleServiceFeign roleServiceFeign;
    private Logger logger = Logger.getLogger(this.getClass());

    /**
     * Find all role string.
     *
     * @param role the role
     * @return the string
     */
    @RequestMapping("/findAllRole")
    public String findAllRole(@RequestBody Role role) {
        logger.info("RoleController findAllRole params:" + role);
        String s = roleServiceFeign.findAllRole(role);
        logger.debug("RoleController findAllRole params:" + role + ",result:" + s);
        return s;
    }

    /**
     * Insert role string.
     *
     * @param role the role
     * @return the string
     */
    @RequestMapping("/insertRole")
    public String insertRole(@RequestBody Role role) {
        logger.info("RoleController insertRole params:" + role);
        String s = roleServiceFeign.insertRole(role);
        logger.debug("RoleController insertRole params:" + role + ",result:" + s);
        return s;
    }

    /**
     * Update role string.
     *
     * @param role the role
     * @return the string
     */
    @RequestMapping("/updateRole")
    public String updateRole(@RequestBody Role role) {
        logger.info("RoleController updateRole params:" + role);
        String s = roleServiceFeign.updateRole(role);
        logger.debug("RoleController updateRole params:" + role + ",result:" + s);
        return s;
    }

    /**
     * Select role and power string.
     *
     * @param role the role
     * @return the string
     */
    @RequestMapping("/selectRoleAndPower")
    public String selectRoleAndPower(@RequestBody Role role) {
        logger.info("RoleController selectRoleAndPower params:" + role);
        String s = roleServiceFeign.selectRoleAndPower(role);
        logger.debug("RoleController selectRoleAndPower params:" + role + ",result:" + s);
        return s;
    }

    /**
     * Select one role power string.
     *
     * @param role the role
     * @return the string
     */
    @RequestMapping("/selectOneRolePower")
    public String selectOneRolePower(@RequestBody Role role) {
        logger.info("RoleController selectOneRolePower params:" + role);
        String s = roleServiceFeign.selectOneRolePower(role);
        logger.debug("RoleController selectOneRolePower params:" + role + ",result:" + s);
        return s;
    }
}
